package com.wn.utils;

import org.apache.shiro.crypto.hash.Md5Hash;

import java.util.UUID;

/**
 * @author yellow Docter
 * @date 2022 -05-17
 * @desc
 */
public class PwdUtils {
    /**
     * 获取盐值
     * @return
     */
    public static String getSalt(){
        //  UUID.randomUUID() 唯一标识
        // substring(0,4) 截取 4个长度
        return UUID.randomUUID().toString().substring(0,4);
    }

    /**
     * shiro的加密操作
     * @param pwd
     * @param salt
     * @return
     */
    public static String getPwd(String pwd,String salt){
        Md5Hash md5Hash = new Md5Hash(pwd,salt,3);
        return md5Hash.toString();

    }

    public static void main(String[] args) {
        String salt = getSalt();
        System.out.println("salt = " + salt);
    }

}
